home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-06-25 | 4.8 KB | 197 lines | [TEXT/CWIE] |
- // ===========================================================================
- // CScreenSaverApp.cp ©1994-1998 Metrowerks Inc. All rights reserved.
- // ===========================================================================
- //
- // The Dashboard Starter demo program with SIOUX supported added
-
- #include "CScreenSaverApp.h"
-
- #include <LApplication.h>
- #include <LCaption.h>
- #include <LGrowZone.h>
- #include <LWindow.h>
- #include <UDrawingState.h>
- #include <UMemoryMgr.h>
- #include <URegistrar.h>
-
- #include <LSIOUXAttachment.h>
- #include <iostream.h>
- #include <LActiveScroller.h>
- #include <UAttachments.h>
- #include <UReanimator.h>
- #include "CPluginTable.h"
- #include "CPluginManager.h"
- #include "CScreenSaverWindow.h"
- #include "UWindows.h"
-
- CPluginManager* gPluginManager = NULL;
-
- const ResIDT WIND_Dashboard = 200;
- const ResIDT WIND_Screen = 1000;
-
- // ===========================================================================
- // • Main Program
- // ===========================================================================
-
- void main()
- {
- // Set Debugging options
- SetDebugThrow_(debugAction_Alert);
- SetDebugSignal_(debugAction_Alert);
-
- InitializeHeap(3); // Initialize Memory Manager
- // Parameter is number of Master Pointer
- // blocks to allocate
-
- // Initialize standard Toolbox managers
- UQDGlobals::InitializeToolbox(&qd);
-
- new LGrowZone(20000); // Install a GrowZone function to catch
- // low memory situations.
- // Parameter is size of reserve memory
- // block to allocated. The first time
- // the GrowZone function is called,
- // there will be at least this much
- // memory left (so you'll have enough
- // memory to alert the user or finish
- // what you are doing).
-
- CScreenSaverApp theApp; // Create instance of your Application
- theApp.Run(); // class and run it
- }
-
-
- // ===========================================================================
- // • CScreenSaverApp Class
- // ===========================================================================
-
- // ---------------------------------------------------------------------------
- // • CScreenSaverApp
- // ---------------------------------------------------------------------------
- // Constructor
-
- CScreenSaverApp::CScreenSaverApp()
- {
- // Register classes for objects created from 'PPob' resources
-
- RegisterClass_(LCaption);
- RegisterClass_(LWindow);
- RegisterClass_(LKeyScrollAttachment);
- RegisterClass_(LColorEraseAttachment);
- RegisterClass_(LStdButton);
- RegisterClass_(CPluginTable);
- RegisterClass_(LActiveScroller);
- RegisterClass_(CScreenSaverWindow);
-
- gPluginManager = new CPluginManager();
-
- }
-
-
- // ---------------------------------------------------------------------------
- // • ~CScreenSaverApp
- // ---------------------------------------------------------------------------
- // Destructor
-
- CScreenSaverApp::~CScreenSaverApp()
- {
- delete gPluginManager;
-
- }
-
-
- // ---------------------------------------------------------------------------
- // • Initialize
- // ---------------------------------------------------------------------------
-
- void
- CScreenSaverApp::Initialize()
- {
- mDisplayWindow = LWindow::CreateWindow(WIND_Dashboard, this);
-
- UReanimator::LinkListenerToControls( this, mDisplayWindow, WIND_Dashboard );
-
- mDisplayWindow->Show();
-
- AddAttachment(new LSIOUXAttachment); // *** Use SIOUX Attachment
-
-
- }
-
- void
- CScreenSaverApp::ListenToMessage(
- MessageT inMessage,
- void* ioParam)
- {
- switch (inMessage) {
-
- case 1500:
- {
- ObeyCommand( 1000 , NULL );
- }
- break;
- }
- }
-
- // ---------------------------------------------------------------------------
- // • ObeyCommand
- // ---------------------------------------------------------------------------
- // Respond to commands
-
- Boolean
- CScreenSaverApp::ObeyCommand(
- CommandT inCommand,
- void *ioParam)
- {
- Boolean cmdHandled = true;
-
- switch (inCommand) {
-
- case 1000:
- {
- LWindow* ScreenSaverWindow = LWindow::CreateWindow(WIND_Screen, this);
- }
- break;
-
-
- default:
- cmdHandled = LApplication::ObeyCommand(inCommand, ioParam);
- break;
- }
-
- return cmdHandled;
- }
-
-
- // ---------------------------------------------------------------------------
- // • FindCommandStatus
- // ---------------------------------------------------------------------------
- // Pass back status of a (menu) command
-
- void
- CScreenSaverApp::FindCommandStatus(
- CommandT inCommand,
- Boolean &outEnabled,
- Boolean &outUsesMark,
- Char16 &outMark,
- Str255 outName)
- {
- switch (inCommand) {
-
- case 1000:
- CPlugin* plugin = 0;
-
- plugin = gPluginManager->GetCurrentPlugin();
- if ( plugin == 0 ) {
- outEnabled = false;
- } else {
- outEnabled = true;
- }
- break;
-
- default:
- LApplication::FindCommandStatus(inCommand, outEnabled, outUsesMark,
- outMark, outName);
- break;
- }
- }